(function(){

	var getCurrentCity = function(){
		var city = remote_ip_info['city'];
	    var $current_city = DOMUtil.getElementsByClassName('current_city')[0];
	    var location;
	    if ($current_city) {
	    	$location  = city;
	    } else {
	    	$location = '无法定位到当前城市，请手动选择';
	    }
	    $current_city.innerHTML = $location;
	};
	
	var $container = DOMUtil.getElementsByClassName('container')[0];

	$container.onclick = function(e) {
		e = e || window.event;
		var target = e.target || e.srcElement;

		var city_id, city_name;
		var className = target.getAttribute('class');
		if ( className && (className == 'current_city' || className == 'city-item')) {
			city_id = target.getAttribute('data-cityid');
			city_name = target.innerHTML;
		} else {
			if (target.tagName == 'LI' 
				&& target.parentNode.getAttribute('class') == 'city-letter-list') {
				var item = target.getElementsByClassName('city-item', target)[0];
				if (item) {
					city_id = item.getAttribute('data-cityid');
					city_name = item.innerHTML;
				}
			}
		}

		if (city_id) {
			alert('当前选择的城市为：id='+ city_id + ', name=' + city_name);
		} 
	}

	getCurrentCity();
})();

